/**
 * @method CodeLabel
 * @description 查询redux中码表的值
 * @prop  {String} code 对应码表的大类的key
 * @prop  {String} value 对应码表数组中的key->value的value
 * @return 返回label文本值
 */

import React from 'react';
import { connect } from 'react-redux';

function CodeLabel(props) {
  const code = props.code;
  const value = props.value;
  const _this = (props.codes[code] && props.codes[code].find((item) => item.key === value)) || {};
  return <span>{_this.value}</span>;
}
export default connect((state) => {
  return {
    codes: state.code || {},
  };
})(CodeLabel);
